class Solution {
    //创建一个存放的数组
    List<List<Integer>> re = new ArrayList<>();
    //存放中间的数组
    List<Integer> temp = new ArrayList<Integer>();
    //List<List<Integer>>的意思是，在数组中再放入数组
    public List<List<Integer>> threeSum(int[] nums) {
        if(nums == null || nums.length <3){
            return re;
        }
        //num中是否存在三个元素a,b,c，a+b+c=0
        //回溯法,先排序
        //排序数组
        Arrays.sort(nums);
        Sum(3,0,0,nums);
        return re;
    }
    // 几个数，当前的位置，目标值，给定数组
    public void Sum(int k , int start , int target , int[] nums){
        int len = nums.length;
        if( k > 2 ){
            //从数组中取数放入Sum方法中，会改变 k , start ,target的值
            for(int i = start ; i < len-2 ; i++){
                if( i > start && nums[i] == nums[i-1]) continue;

                temp.add(nums[i]);
                Sum(k-1, i+1 ,target-nums[i],nums);
                //这个是回退，需要去参考回溯法。
                temp.remove(temp.size()-1);
            }
           // 双指针法，和盛水的问题相同；找到固定的数
        }else if(k == 2){
            int right = len -1;
            int left = start;
            while(left < right){
                int add = nums[left] + nums[right];
                //相同说明当前的两个值能解决这个问题
                if(add == target ){
                    temp.add(nums[left]);
                    temp.add(nums[right]);
                    re.add(new ArrayList<Integer>(temp));
                    temp.remove(temp.size()-1);
                    temp.remove(temp.size()-1);
                    //继续寻找,当左右的后面一个与现在的值相等的时候，跳过这个元素；因为不允许重复
                    while (left < right && nums[left] == nums[left+1]) left++;
                    while (left < right && nums[right] == nums[right-1]) right--;
                    //没有重复，两边同时移动；
                    right--;
                    left++;
                    //(下次注意一点！！！！！因为粗心大意少了else 找了半天的错!!!!)
                }else
                //因为已经排好序了，所以一定左边小右边大
                if(add > target){
                    do{
                        right--;
                    }while (left < right && nums[right] == nums[right+1]);
                }else{
                    do{
                        left++;
                    }while(left < right && nums[left] == nums[left-1]);
                }
            }
        }
    }
}

public class MainClass {
    public static int[] stringToIntegerArray(String input) {
        input = input.trim();
        input = input.substring(1, input.length() - 1);
        if (input.length() == 0) {
          return new int[0];
        }
    
        String[] parts = input.split(",");
        int[] output = new int[parts.length];
        for(int index = 0; index < parts.length; index++) {
            String part = parts[index].trim();
            output[index] = Integer.parseInt(part);
        }
        return output;
    }
    
    public static String integerArrayListToString(List<Integer> nums, int length) {
        if (length == 0) {
            return "[]";
        }
    
        String result = "";
        for(int index = 0; index < length; index++) {
            Integer number = nums.get(index);
            result += Integer.toString(number) + ", ";
        }
        return "[" + result.substring(0, result.length() - 2) + "]";
    }
    
    public static String integerArrayListToString(List<Integer> nums) {
        return integerArrayListToString(nums, nums.size());
    }
    
    public static String int2dListToString(List<List<Integer>> nums) {
        StringBuilder sb = new StringBuilder("[");
        for (List<Integer> list: nums) {
            sb.append(integerArrayListToString(list));
            sb.append(",");
        }
    
        sb.setCharAt(sb.length() - 1, ']');
        return sb.toString();
    }
    
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            int[] nums = stringToIntegerArray(line);
            
            List<List<Integer>> ret = new Solution().threeSum(nums);
            
            String out = int2dListToString(ret);
            
            System.out.print(out);
        }
    }
}